//////////////////////////////////////////////////////////////////////////
//
// GAM203
// Sound Manager
// SoundMgr.h
// 
// Scott Taylor
// Qantm College
//
//////////////////////////////////////////////////////////////////////////

#ifndef SOUNDMGR_H
#define SOUNDMGR_H

#include <vector>
#include "Singleton.h"

class SoundSample;
class SoundEmitter;

class SoundMgr : public Singleton<SoundMgr>
{
public:
	SoundMgr();
	virtual ~SoundMgr();

	struct VectorTriplet  // For use in calls to FMOD
	{
		VectorTriplet() : x(0), y(0), z(0) {}
		float x, y, z;
	};

	bool Setup();
	void Shutdown();

	void Update();

	void SetListener(float a_xPos, float a_yPos, float a_zPos, float a_xDir, float a_yDir, float a_zDir);

	SoundEmitter* CreateEmitter(const char* a_pFilename, bool a_is3d);
	SoundEmitter* CreateEmitter(SoundEmitter* a_pCopyEmitter);

	float GetCPUUsage() const;

	//Pre load all required sounds
	bool PreloadSample(const char* a_pFileName, bool a_is3d);

private:

	SoundSample* LoadSampleInternal(const char* a_pFilename, bool a_is3d);
	SoundSample* FindSampleInternal(const char* a_pFilename);

	SoundEmitter* CreateEmitterInternal(SoundSample* a_pSample);

private:
	typedef std::vector<SoundSample*> SoundSampleArray;
	SoundSampleArray m_samples;

	typedef std::vector<SoundEmitter*> SoundEmitterArray;
	SoundEmitterArray m_emitters;

	VectorTriplet m_listenerPos;  // Listener position in world space
	VectorTriplet m_listenerDir;  // Listener facing direction (unit vector)
};

#endif  // SOUNDMGR_H
